package org.amse.korovkin.ciphering.view;

import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.EtchedBorder;
import javax.swing.plaf.metal.MetalLookAndFeel;
import org.amse.korovkin.ciphering.view.CipherActions.*;
import org.amse.korovkin.ciphering.view.MainJFrameActions.*;

public class MyJMenuBar extends JMenuBar {
    CipheringJFrame parent = null;
    JMenu file = new JMenu("File");
    JMenu actions = new JMenu("Actions");
    JMenu help = new JMenu("Help");
    JMenuItem about = new JMenuItem("About");
    JMenuItem open = new JMenuItem("Open");
    JMenuItem clearSrc = new JMenuItem("ClearSRC");
    JMenuItem clearDst = new JMenuItem("ClearDST");
    JMenuItem exchange = new JMenuItem("Exchange");
    JMenuItem exit = new JMenuItem("Exit");
    JMenuItem encrypt = new JMenuItem("Encrypt");
    JMenuItem decrypt = new JMenuItem("Decrypt");
    JMenuItem attack = new JMenuItem("Attack");

    public MyJMenuBar(CipheringJFrame jFrame) {
        parent = jFrame;
        file.add(open);
        file.add(clearSrc);
        file.add(clearDst);
        file.add(exchange);
        file.addSeparator();
        file.add(exit);
        actions.add(encrypt);
        actions.add(decrypt);
        actions.add(attack);
        help.add(about);
        this.add(file);
        this.add(actions);
        this.add(help);
        this.setBorder(new EtchedBorder(MetalLookAndFeel.getControl()
                , UIManager.getColor("MenuBar.borderColor")));

        exit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        about.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                new AboutJDialog(parent);
            }
        });
        exchange.setAction(new ExchangeAction(parent));
        clearSrc.setAction(new ClearSrcAction(parent));
        clearDst.setAction(new ClearDstAction(parent));
        open.setAction(new OpenSrcAction(parent));
        encrypt.setAction(new EncryptAction(parent));
        decrypt.setAction(new DecryptAction(parent));
        attack.setAction(new AttackAction(parent));
    }
    
}
